/**
 * 角色表格
 */
import React, { Component } from 'react';
import moment from 'moment';
import PropTypes from 'prop-types';
import { Link } from 'dva/router';
import { Table } from 'antd';
import getPagination from '../../components/pagination';
import { onSetItemDecorator } from '../../components/export';

const styles = {
  defaultV: {
    color: '#ccc'
  }
}

@onSetItemDecorator
class MyTable extends Component {
  constructor(props, context) {
    super(props, context);
    // const { notShow = [] } = props;
    //
    // if (props.edit) this.columns = columns.map(c => c.key !== 'opt' ? c : { ...c, render: this.renderOpt });
    // else this.columns = columns.filter(c => c.key !== 'opt');
    // this.columns = this.columns.filter(c => !notShow.includes(c.key));
  }

  onChange = selectedRowKeys => {
    this.props.select(selectedRowKeys);
  };

  // renderOpt = (text, record) => {
  //   return <a onClick={() => this.props.edit(record.id)}>详情</a>;
  // }

  render() {
    const { list, selectKeys, pagination, currentCol } = this.props;
    const rowSelection = {
      onChange: this.onChange,
      selectedRowKeys: selectKeys
    };
    return (
      <Table
        rowKey="id"
        dataSource={list}
        columns={currentCol}
        pagination={pagination}
        rowSelection={rowSelection}
        scroll={currentCol.length > 10 ? { x: 2000 } : {}}
      />
    );
  }
}

MyTable.propTypes = {

};

export default MyTable;
